home *** CD-ROM | disk | FTP | other *** search
- * $Revision Header *** Header built automatically - do not edit! ***********
- *
- * (C) Copyright 1992 by Torsten Jürgeleit
- *
- * Name .....: files2.asm
- * Created ..: Wednesday 22-Oct-92 15:23:51
- * Revision .: 0
- *
- * Date Author Comment
- * ========= ==================== ====================
- * 22-Oct-92 Torsten Jürgeleit Created this file!
- *
- ****************************************************************************
- *
- * DOS calls between open and close of dos library -> neccessary for
- * DOS calls from within intuisup.library
- *
- * $Revision Header ********************************************************/
-
- ;---------------------------------------------------------------------------
- ; Support macros
- ;---------------------------------------------------------------------------
-
- PUSH MACRO
- movem.l \1,-(sp)
- ENDM
-
- PULL MACRO
- movem.l (sp)+,\1
- ENDM
-
- CALLSYS MACRO
- XREF _LVO\1
- jsr _LVO\1(a6)
- ENDM
-
- ;---------------------------------------------------------------------------
- ; External definitions
- ;---------------------------------------------------------------------------
-
- XDEF _dos_open
- XDEF _dos_read
- XDEF _dos_close
-
- ;---------------------------------------------------------------------------
- ; BPTR dos_open(BYTE *name, LONG flags)
- ; a0 d0
- ;---------------------------------------------------------------------------
-
- _dos_open:
- PUSH d2-d3/a2/a6
-
- ; --- save parameters
- move.l a0,a2 ; a2 := file name ptr
- move.l d0,d2 ; d2 := flags
- moveq #0,d3 ; d3 := return code
-
- ; --- open dos library
- move.l (4).w,a6 ; a6 := SysBase
- lea dos_name(pc),a1 ; a1 := library name
- moveq #0,d0 ; d0 := version
- CALLSYS OpenLibrary
- tst.l d0
- beq.s do_exit
-
- ; --- call DOS function Open()
- move.l d0,a6 ; a6 := DosBase
- move.l a2,d1 ; d1 := file name ptr
- ; d2 := flags
- jsr -$1e(a6) ; CALLSYS Open -> Bug in c16.lib (POSITIVE lib offset)
- move.l d0,d3 ; d3 := BPTR to file handle
-
- ; --- close dos library
- move.l a6,a1 ; a1 := DosBase
- move.l (4).w,a6 ; a6 := SysBase
- CALLSYS CloseLibrary
-
- do_exit:
- ; --- prepare return code
- move.l d3,d0
-
- PULL d2-d3/a2/a6
- rts
-
- ;---------------------------------------------------------------------------
- ; LONG dos_read(BPTR fh, BYTE *buffer, LONG size);
- ; a0 a1 d0
- ;---------------------------------------------------------------------------
-
- _dos_read:
- PUSH d2-d4/a2-a3/a6
-
- ; --- save parameters
- move.l a0,a2 ; a2 := BPTR to file handle
- move.l a1,a3 ; a3 := buffer ptr
- move.l d0,d3 ; d3 := size
- moveq #-1,d4 ; d4 := return code
-
- ; --- open dos library
- move.l (4).w,a6 ; a6 := SysBase
- lea dos_name(pc),a1 ; a1 := library name
- moveq #0,d0 ; d0 := version
- CALLSYS OpenLibrary
- tst.l d0
- beq.s dr_exit
-
- ; --- call DOS function Read()
- move.l d0,a6 ; a6 := DosBase
- move.l a2,d1 ; d1 := BPTR to file handle
- move.l a3,d2 ; d2 := buffer ptr
- ; d3 := size
- jsr -$2a(a6) ; CALLSYS Read -> Bug in c16.lib (POSITIVE lib offset)
- move.l d0,d4 ; d4 := num of characters read
-
- ; --- close dos library
- move.l a6,a1 ; a1 := DosBase
- move.l (4).w,a6 ; a6 := SysBase
- CALLSYS CloseLibrary
-
- dr_exit:
- ; --- prepare return code
- move.l d4,d0
-
- PULL d2-d4/a2-a3/a6
- rts
-
- ;---------------------------------------------------------------------------
- ; VOID dos_close(BPTR fh);
- ; a0
- ;---------------------------------------------------------------------------
-
- _dos_close:
- PUSH a2/a6
-
- ; --- save parameters
- move.l a0,a2 ; a2 := BPTR to file handle
-
- ; --- open dos library
- move.l (4).w,a6 ; a6 := SysBase
- lea dos_name(pc),a1 ; a1 := library name
- moveq #0,d0 ; d0 := version
- CALLSYS OpenLibrary
- tst.l d0
- beq.s dc_exit
-
- ; --- call DOS function Close()
- move.l d0,a6 ; a6 := DosBase
- move.l a2,d1 ; d1 := BPTR to file handle
- jsr -$24(a6) ; CALLSYS Close -> Bug in c16.lib (POSITIVE lib offset)
-
- ; --- close dos library
- move.l a6,a1 ; a1 := DosBase
- move.l (4).w,a6 ; a6 := SysBase
- CALLSYS CloseLibrary
-
- dc_exit:
- PULL a2/a6
- rts
-
- ;---------------------------------------------------------------------------
- ; Static data
- ;---------------------------------------------------------------------------
-
- dos_name:
- dc.b "dos.library"
-
- END
-